package com.biz.primus.account.utils;

import com.biz.primus.base.exception.BizBusinessException;
import com.biz.primus.model.sso.account.vo.UserVo;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Created by defei on 11/18/17.
 */
public class SSOUtils {

    public static UserVo getUserOfLogin() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal instanceof UserVo) {
            return (UserVo) principal;
        }
        throw new BizBusinessException("User not login.");
    }

}
